<template>
	<view>
		<view class="toububox">
			<!-- #ifdef MP-WEIXIN -->
			<!-- <button class="dibubox" open-type="contact" hover-class="none" bindcontact="handleContact"
				session-from="sessionFrom">
				<view class="flexright">

					<view class="kefu" @click="goCustomer">
						<image src="../static/image/system/kef.png" mode=""></image>
					</view>
				</view>
			</button> -->
			<!-- #endif -->
			<!-- #ifdef APP-PLUS -->
			<view class="flexright">
				<view class="kefu" @click="goCustomer">
					<image src="../static/image/system/kef.png" mode=""></image>
				</view>

			</view>
			<!-- #endif -->

		</view>
		<view class="mainpadding" style="position: relative; top: -220rpx;">
			<!-- 个人信息 -->
			<view class="touxx mainpadding radius shadow">
				<view class="flexbetween" @click="jumper('/pages/login/login')" v-if="!is_login">
					<view class="flexleft">
						<view class="touxiang margin_right2">
							<image src="@/static/image/logo.png" mode=""></image>
						</view>
						<view class="">
							<view class="sanshier fonweight xiaohei">未登录，点击去登陆</view>
							<!-- <view class="ershiba fonweight xiaohei margin_top2">登陆后可查看更多详细内容~</view> -->
						</view>
					</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view class="flexbetween" @click="jumper('/pages_mypage/gerenziliao')" v-if="is_login">
					<view class="flexleft">
						<view class="touxiang margin_right2">
							<image :src="userInfo.avatar_text" mode=""></image>
						</view>
						<view class="">
							<view class="sanshier fonweight xiaohei">{{userInfo.nickname}}</view>
							<view class="ershiba fonweight xiaohei margin_top2">{{userInfo.mobile}}</view>
						</view>
					</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershiwu flexcenter" @click="jumper('/pages_mypage/wodeyue')">
						<view class="">
							<view class="bigtext fonweight xiaohei textcenter" v-if="userInfo.money">
								{{userInfo.money.length>5?formatNumber(userInfo.money):userInfo.money}}
							</view>
							<view class="bigtext fonweight xiaohei textcenter" v-else>0.00</view>
							<view class="ershil nofonweight xiaohei margin_top1 textcenter">余额</view>
						</view>
					</view>
					<view class="ershiwu flexcenter" @click="jumper('/pages_mypage/jifenduihuan')">
						<view class="">
							<view class="bigtext fonweight xiaohei textcenter" v-if="userInfo.score">
								{{ formatNumber(userInfo.score) || 0}}
							</view>
							<view class="bigtext fonweight xiaohei textcenter" v-else>0</view>
							<view class="ershil nofonweight xiaohei margin_top1 textcenter">积分</view>
						</view>
					</view>
					<view class="ershiwu flexcenter" @click="jumper('/pages_mypage/youhuijuan')">
						<view class="">
							<view class="bigtext fonweight xiaohei textcenter" v-if="userInfo.coupon_num">
								{{ formatNumber(userInfo.coupon_num) || 0}}
							</view>
							<view class="bigtext fonweight xiaohei textcenter" v-else>0</view>
							<view class="ershil nofonweight xiaohei margin_top1 textcenter">优惠券</view>
						</view>
					</view>
					<view class="ershiwu flexcenter" @click="jumper('/pages_mypage/wodeguanzhu')">
						<view class="">
							<view class="bigtext fonweight xiaohei textcenter" v-if="userInfo.collect_num">
								{{ formatNumber(userInfo.collect_num) || 0}}
							</view>
							<view class="bigtext fonweight xiaohei textcenter" v-else>0</view>
							<view class="ershil nofonweight xiaohei margin_top1 textcenter">我的关注</view>
						</view>
					</view>
				</view>
				<view class="dingwei margin_top" v-if="!isSH" @click="jumper('/pages_mypage/huiyuank')">
					<image class="huiytu" src="../static/image/system/huiyk.png" mode=""></image>
					<view class="flexbetween huner">
						<view class="xiaoka fonweight ershiba">会员卡</view>
						<view class="kabtn">{{userInfo.vip_time_text?userInfo.start_time_text+'生效'+userInfo.vip_time_text+"到期":'申请开通会员'}}</view>
					</view>
				</view>

			</view>
			<!-- 我的订单 -->
			<view class="mainpadding ffffff radius margin_top">
				<view class="flexbetween">
					<view class="sanshier fonweight xiaohei">我的订单</view>
					<!-- <u-icon name="arrow-right"></u-icon> -->
				</view>
				<view class="flexbetween margin_top4">
					<view class="flexcenter ershiwu" @click="jumper('/pages_mypage/changdidd')">
						<view class="">
							<view class="dindicon">
								<image src="../static/image/system/cddd.png" mode=""></image>
							</view>
							<view class="strongtext nofonweight xiaohei margin_top1">场地订单</view>
						</view>
					</view>
					<view class="flexcenter ershiwu" @click="jumper('/pages_mypage/kechengdd')">
						<view class="">
							<view class="dindicon">
								<image src="../static/image/system/kcdd.png" mode=""></image>
							</view>
							<view class="strongtext nofonweight xiaohei margin_top1">课程订单</view>
						</view>
					</view>
					<view class="flexcenter ershiwu" @click="jumper('/pages_mypage/saishidd')">
						<view class="">
							<view class="dindicon">
								<image src="../static/image/system/ssdd.png" mode=""></image>
							</view>
							<view class="strongtext nofonweight xiaohei margin_top1">赛事订单</view>
						</view>
					</view>
					<view class="flexcenter ershiwu" @click="jumper('/pages_mypage/huodongdd')">
						<view class="">
							<view class="dindicon">
								<image src="../static/image/system/hddd.png" mode=""></image>
							</view>
							<view class="strongtext nofonweight xiaohei margin_top1">活动订单</view>
						</view>
					</view>
					<view class="flexcenter ershiwu" @click="jumper('/pages_mypage/wodedingdan')">
						<view class="">
							<view class="dindicon">
								<image src="../static/image/system/scdd.png" mode=""></image>
							</view>
							<view class="strongtext nofonweight xiaohei margin_top1">商城订单</view>
						</view>
					</view>
					<view class="flexcenter ershiwu" @click="jumper('/pages_mypage/sanchangdd')">
						<view class="">
							<view class="dindicon">
								<image src="../static/image/system/cddd.png" mode=""></image>
							</view>
							<view class="strongtext nofonweight xiaohei margin_top1">散场订单</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 我的服务 -->
			<view class="mainpadding ffffff margin_top">
				<!-- <view class="flexbetween xiahuaxian" @click="jumper('/pages_mypage/wodefenx')">
					<view class="ershil nofonweight xiaohei margin_top1">我的分销</view>
					<u-icon name="arrow-right"></u-icon>
				</view> -->
				<view class="flexbetween xiahuaxian" @click="jumper('/pages_mypage/kanjialist')">
					<view class="ershil nofonweight xiaohei margin_top1">我发起的砍价</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_mypage/kebiaolist')">
					<view class="ershil nofonweight xiaohei margin_top1">我的课表</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view class="flexbetween xiahuaxian margin_top" v-if="userInfo.cgxs" @click="xiaoshou">
					<view class="ershil nofonweight xiaohei margin_top1">进入销售端</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_mypage/wodebaoming')">
					<view class="ershil nofonweight xiaohei margin_top1">我的报名</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_mypage/wodedianzip')">
					<view class="ershil nofonweight xiaohei margin_top1">我的电子票</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<!-- <view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_mypage/wodefabu')">
					<view class="ershil nofonweight xiaohei margin_top1">发布活动</view>
					<u-icon name="arrow-right"></u-icon>
				</view> -->
				<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_mypage/kaijufapiao')">
					<view class="ershil nofonweight xiaohei margin_top1">开具发票</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view class="flexbetween xiahuaxian margin_top"  v-if="!isSH" @click="jumper('/pages_mypage/wodehyk')">
					<view class="ershil nofonweight xiaohei margin_top1">我的会员卡</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_xiaoshou/yaoqinghy')">
					<view class="ershil nofonweight xiaohei margin_top1">邀请好友</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<!-- <view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_mypage/woyaohezuo')">
					<view class="ershil nofonweight xiaohei margin_top1">我要合作</view>
					<u-icon name="arrow-right"></u-icon>
				</view> -->
				<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages_mypage/wodehz')">
					<view class="ershil nofonweight xiaohei margin_top1">我的合作</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<!-- #ifdef MP-WEIXIN -->
				<button class="dibubox" open-type="contact" hover-class="none" bindcontact="handleContact"
					session-from="sessionFrom">
					<view class="flexbetween xiahuaxian margin_top">
						<view class="ershil nofonweight xiaohei margin_top1">联系客服</view>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</button>
				<!-- #endif -->
				<!-- <view class="flexbetween xiahuaxian margin_top"
					v-if="is_login && userInfo.userzbfapply &&  userInfo.userzbfapply.status==2"
					@click="jumper('/pages_mypage/hezuogl')">
					<view class="ershil nofonweight xiaohei margin_top1">合作管理</view>
					<u-icon name="arrow-right"></u-icon>
				</view> -->
				<view class="flexbetween margin_top" @click="jumper('/pages_mypage/xitongshez')">
					<view class="ershil nofonweight xiaohei margin_top1">系统设置</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
		</view>
		<tabbaryhd current=3></tabbaryhd>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				is_login: false,
				userInfo: {},
				isSH:false
			}
		},
		onShow() {
			this.is_login = httpRequest.checkIsLogin();
			if (this.is_login) {
				this.userinfomsg()
			} else {
				this.userInfo = {}
			}
		},
		onLoad() {
			uni.hideTabBar()
			this.getsystem()
		},
		onShareAppMessage: function() {
			return {
				title: '动佳',
				path: '/pages/kaiping'
			}
		},
		onShareTimeline: function() {
			return {
				title: '动佳',
				path: '/pages/kaiping'
			}
		},
		methods: {
			getsystem() {
				let _this = this
				let system = uni.getSystemInfoSync()
				let version_code = system.appVersionCode
				let platform = system.platform
				httpRequest.request('/api/index/checkApply', 'GET', {
					platform,
					version_code
				}).then(res => {
					console.log(version_code, platform, res);
					this.isSH = res.data
				})
			},
			goCustomer() {
				let wechat = null
				plus.share.getServices(res => {
					wechat = res.find(i => i.id === 'weixin')
					if (wechat) {
						wechat.openCustomerServiceChat({
							corpid: 'ww36460fe7b7151dcb', //企业ID
							url: 'https://work.weixin.qq.com/kfid/kfc82d580dc8f0a05ee', //客服地址
						}, src => {
							console.log("success:")
						}, err => {
							console.log("error:")
						})
					} else {
						uni.showToast({
							title: '当前环境不支持微信操作',
							icon: "error"
						});
					}
				});
			},
			xiaoshou() {
				uni.switchTab({
					url: "/pages/index"
				})
			},
			formatNumber(num) {
				num = Number(num);
				if (num == 0 || (num > 0 && num < 10000)) {
					return num + '';
				} else {
					return (num / 10000).toFixed(0) + '万+';
				}
			},
			userinfomsg() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			jumper(url) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				if (url == "/pages_mypage/woyaohezuo" && this.userInfo.userzbfapply) {
					uni.navigateTo({
						url: "/pages_mypage/hezuosh"
					})
					return false
				}
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.dindicon {
		width: 50rpx;
		height: 50rpx;
		margin: auto;

		image {
			margin: auto;
			width: 100%;
			height: 100%;
		}
	}

	.kabtn {
		padding: 6rpx 20rpx 8rpx;
		background-color: #6A4B18;
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		border-radius: 30rpx;
	}

	.huner {
		position: absolute;
		bottom: 30rpx;
		right: 30rpx;
		width: 90%;
	}

	.huiytu {
		height: 100rpx;
		width: 100%;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.ershiwu {
		width: 25%;
	}

	.touxiang {
		width: 150rpx;
		height: 150rpx;
		border-radius: 50%;

		image {
			width: 100%;
			height: 100%;
			border-radius: 50%;
		}
	}

	page {
		background: #F9F9F9;
	}

	.kefu {
		width: 48rpx;
		height: 48rpx;

		image {
			width: 100%;
			height: 100%;
		}

	}

	.toububox {
		padding: 108rpx 30rpx 220rpx;
		background: linear-gradient(180deg, #1BA95B 0%, #FFFFFF 100%);
	}
</style>